var thinkjs = require('thinkjs');
var path = require('path');
var childProcess = require('child_process');

var rootPath = path.dirname(__dirname);
var env_type="production";

var instance = new thinkjs({
    APP_PATH: rootPath + path.sep + 'app',
    RUNTIME_PATH: rootPath + path.sep + 'runtime',
    ROOT_PATH: rootPath,
    RESOURCE_PATH: __dirname,
    env: env_type
});

var p = childProcess.exec(`cross-env NODE_ENV=${env_type} webpack --config webpack.config.js --optimize-minimize -p`);
p.stdout.pipe(process.stdout);

var p1 = childProcess.exec(`cross-env NODE_ENV=${env_type} npm run compile`);
p1.stdout.pipe(process.stdout);

instance.run(true);
